import java.util.Scanner;

public class Class1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long X = scanner.nextInt();
        String path = scanner.next();
        if (N==0)
        {
            System.out.println(X);
            return;
        }
        for (int i=0;i<N;i++){
            //定义一个变量确定节点是左节点还是右节点

                if (path.charAt(i)=='U'){
                    if (X==1)
                        continue;
                   X =X/2;

                }else if (path.charAt(i)=='L'){
                    X = 2*X;

                }else if (path.charAt(i)=='R'){
                    X =2*X+1;
                }

        }
        System.out.println(X);


    }
}
